package main

import (
	"github.com/lxn/walk"
	"github.com/lxn/win"
)

func showFloatWindow() {
	// 创建主窗口
	fw, _ := walk.NewMainWindow()
	err = fw.SetLayout(walk.NewHBoxLayout())
	ifErr(err)

	// 设置无边框样式
	win.SetWindowLongPtr(fw.Handle(), win.GWL_STYLE, win.WS_POPUP|win.WS_VISIBLE)

	// 设置窗口始终在最前
	win.SetWindowPos(
		fw.Handle(),
		win.HWND_TOPMOST,
		int32(float32(win.GetSystemMetrics(win.SM_CXSCREEN))*0.91),
		int32(float32(win.GetSystemMetrics(win.SM_CYSCREEN))*0.87),
		300, 200, // 位置和大小
		//win.SWP_SHOWWINDOW|win.SWP_NOMOVE|win.SWP_NOSIZE,
		win.SWP_SHOWWINDOW|win.SWP_NOSIZE,
	)

	floatBtn, err := walk.NewPushButton(fw)
	ifErr(err)
	err = floatBtn.SetText("点名")
	ifErr(err)
	floatBtn.Clicked().Attach(func() {
		checkNameList()
		err = floatBtn.SetText(randName())
		ifErr(err)
	})

	// 显示窗口
	fw.Show()
}
